package cn.edu.scau.cmi.xiaozecheng.factory;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;


/**
 * @author xiao
 * @date 2019/10/12/012 2:50 PM
 */
public class Controller {
    @FXML
    private TextArea resultText;
    @FXML
    private Button button;
    @FXML
    private ComboBox<String> choice;


    public String getChoice() {
        return choice.getValue();
    }

    public MeatFactory getFactory() {
        String type = getChoice();
        if ("beef".equalsIgnoreCase(type)) {
            return new BeefMeatFactory();
        } else if ("Chicken".equalsIgnoreCase(type)) {
            return new ChickenMeatFactory();
        } else if ("Pork".equalsIgnoreCase(type)) {
            return new PorkMeatFactory();
        }
        return null;
    }

    public void showResult() {
        MeatFactory meatFactory = getFactory();
        resultText.appendText(meatFactory.getInstance().cook() + '\n');
    }

}
